package com.ms.player;

import java.io.Serializable;
import java.math.BigDecimal;

import com.xpec.c4.game.utility.GUID;

public class PlayerRedis implements Serializable {

	private static final long serialVersionUID = 1L;

	/*
	 * <pre>
	 * 自身id
	 * UUID先不支援 Utility的copy , 原寫法沒檢查type, 會強迫給職結果爛掉, 與其讓她每次檢查class type不如先標記
	 * 
	 * @see com.ms.game.db.util.Utility
	 * </pre>
	 */
	private String guid = "";

	/** 帳戶id */
	private String accountId = "";

	/** 營運商accountID */
	private String cooperatorAccountId = "";

	/** 名稱 */
	private String name = "";

	/** h5 agent 回傳資料時用的參數 (json) */
	private String agentData = "";

	/** 金幣 */
	private BigDecimal goldCoin = BigDecimal.ZERO;

	/** 角色創建時間 */
	private long createTime = 0l;

	/** 營運商 id */
	private String venderId = "";

	/** 子營運商 id */
	private String subVenderId = "";

	public PlayerRedis(Player player) {
		setGuid(player.getGuid().toString());
		setAccountId(player.getAccountId().toString());
		setCooperatorAccountId(player.getCooperatorAccountId());
		setName(player.getName());
		setAgentData(player.getAgentData());
		setGoldCoin(player.getGoldCoin());
		setCreateTime(player.getCreateTime());
		setVenderId(player.getVenderId());
		setSubVenderId(player.getSubVenderId());
	}

	public Player toPlayer() {
		Player player = new Player();

		player.setGuid(GUID.parseUUID(getGuid()));
		player.setAccountId(GUID.parseUUID(getAccountId()));
		player.setCooperatorAccountId(getCooperatorAccountId());
		player.setName(getName());
		player.setFacephoto("head3");
		player.setLevel(50);
		player.setVip(1);
		player.setNameNumber("0000");
		player.setAgentData(getAgentData());
		player.setgoldCoin(getGoldCoin());
		player.setCreateTime(getCreateTime());
		player.setVenderId(getVenderId());
		player.setSubVenderId(getSubVenderId());

		return player;
	}

	public String getGuid() {
		return guid;
	}

	public void setGuid(String guid) {
		this.guid = guid;
	}

	public String getAccountId() {
		return accountId;
	}

	public void setAccountId(String accountId) {
		this.accountId = accountId;
	}

	public String getCooperatorAccountId() {
		return cooperatorAccountId;
	}

	public void setCooperatorAccountId(String cooperatorAccountId) {
		this.cooperatorAccountId = cooperatorAccountId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAgentData() {
		return agentData;
	}

	public void setAgentData(String agentData) {
		this.agentData = agentData;
	}

	public BigDecimal getGoldCoin() {
		return goldCoin;
	}

	public void setGoldCoin(BigDecimal goldCoin) {
		this.goldCoin = goldCoin;
	}

	public long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}

	public String getVenderId() {
		return venderId;
	}

	public void setVenderId(String venderId) {
		this.venderId = venderId;
	}

	public String getSubVenderId() {
		return subVenderId;
	}

	public void setSubVenderId(String subVenderId) {
		this.subVenderId = subVenderId;
	}
}
